/*
 * Eugen Stoian <stoian.e@gmail.com> 2010
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef REAL_H
#define REAL_H
#include <QString>
class Real
{
public:
    enum Limits { Finite = 0x0, PositiveInfinity=0x1, NegativeInfinity=0x2, NotANumber=0x4 };

    static Real& epsilon();
    static Real& nan();
    static Real& positiveInfinity();
    static Real& negativeInfinity();
    static Real& pi();
    static Real& e();
    static Real& gamma();
    static Real& phi();
    static Real& lambda();
    static Real& alpha();
    static Real& delta();

    Real(double value = 0.0, Real::Limits limit = Real::Finite);
    Real(const Real& r);
    virtual ~Real();
    Real& operator=(const Real& r);
    Real& operator=(double d);

    bool isNan() const;
    bool isPositiveInfinity() const;
    bool isNegativeInfinity() const;
    bool isInfinity() const;
    bool isFinite() const;
    bool isStrictPositive() const;
    bool isStrictNegative() const;
    bool isPositive() const;
    bool isNegative() const ;
    bool isZero() const;
    bool isPositiveZero() const;
    bool isNegativeZero() const;
    bool isInvertible() const;
    bool isFalse() const;
    bool isTrue() const;

    int sign() const;

    operator double() const {
        return _value;
    }

    QString toString() const;

    friend double operator-(const Real& l );
    friend double operator+(const Real& l, double r);
    friend double operator-(const Real& l, double r);
    friend double operator*(const Real& l, double r);
    friend double operator/(const Real& l, double r);
    /*
    friend bool operator==(const Real& l, double r);
    friend bool operator!=(const Real& l, double r);
    friend bool operator<(const Real& l, double r);
    friend bool operator<=(const Real& l, double r);
    friend bool operator>(const Real& l, double r);
    friend bool operator>=(const Real& l, double r);
    friend bool operator&&(const Real& l, double r);
    friend bool operator||(const Real& l, double r);
    */
protected:
    double _value;
    Limits _limit;
};

double operator-(const Real& l );
double operator+(const Real& l, double r);
double operator-(const Real& l, double r);
double operator*(const Real& l, double r);
double operator/(const Real& l, double r);
/*
bool operator==(const Real& l, double r);
bool operator!=(const Real& l, double r);
bool operator<(const Real& l, double r);
bool operator<=(const Real& l, double r);
bool operator>(const Real& l, double r);
bool operator>=(const Real& l, double r);
bool operator&&(const Real& l, double r);
bool operator||(const Real& l, double r);
*/
Real r_sin(const Real& r);
Real r_cos(const Real& r);
Real r_tan(const Real& r);
Real r_sinh(const Real& r);
Real r_cosh(const Real& r);
Real r_tanh(const Real& r);
Real r_asin(const Real& r);
Real r_acos(const Real& r);
Real r_atan(const Real& r);
Real r_asinh(const Real& r);
Real r_acosh(const Real& r);
Real r_atanh(const Real& r);
Real r_log(const Real& r);
Real r_sqrt(const Real& r);

#endif // REAL_H
